//
//  CityTravelTableViewCell.m
//  TravelFollowYourHeart
//
//  Created by ENERGY on 2017/12/18.
//  Copyright © 2017年 Lwx. All rights reserved.
//

#import "CityTravelTableViewCell.h"
#import "TravelLikeButton.h"
#define collectionBtnW 60

@interface CityTravelTableViewCell()
@property (nonatomic, strong)UIImageView * contentImage;
@property (nonatomic, strong)TravelLikeButton * collectionBtn;
@property (nonatomic, strong)UILabel * titleLable;

@end

@implementation CityTravelTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = getColor(@"e5e5e5");
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.contentImage];
        [self.contentView addSubview:self.collectionBtn];
        [self.contentView addSubview:self.titleLable];
        
    }return self;
}

- (TravelLikeButton *)collectionBtn{
    if (!_collectionBtn) {
        _collectionBtn = [[TravelLikeButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - collectionBtnW - 10, self.titleLable.top - 10 - 20, collectionBtnW, 20)];

        [_collectionBtn setBackgroundColor:[UIColor clearColor]];
        [_collectionBtn setTitle:@"3321" forState:UIControlStateNormal];
        [_collectionBtn setImage:[UIImage imageNamed:@"icon_shoucang"] forState:UIControlStateNormal];
        [_collectionBtn setImage:[UIImage imageNamed:@"icon_yishoucang"] forState:UIControlStateSelected];
        [_collectionBtn addTarget:self action:@selector(collectionBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }return _collectionBtn;
}

- (UIImageView *)contentImage{
    if (!_contentImage) {
        _contentImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 181)];
    }return _contentImage;
}

- (UILabel *)titleLable{
    if (!_titleLable) {
        _titleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, self.contentImage.bottom, SCREEN_WIDTH, 39)];
        _titleLable.backgroundColor = [UIColor greenColor];
        _titleLable.font = [UIFont systemFontOfSize:14];
        _titleLable.textAlignment = NSTextAlignmentCenter;
    }return _titleLable;
}

- (void)collectionBtnClick:(TravelLikeButton *)btn{
    btn.selected = !btn.selected;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
